﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using QLHD.DAL;
using QLHD.DAL.Manipulation;
using QLHD.Entity.Manipulation;

namespace QLHD.BUS
{
    public class BoBussiness
    {
        #region DanhMuc
        public static List<DanhMuc.DanhMucHopDong> DanhMucHopDong_ListAll()
        {
            return DanhMuc_DAL.DanhMucHopDong_ListAll();
        }
        public static List<DanhMuc.DanhMucNhanSu> DanhMucNhanSu_ListAll()
        {
            return DanhMuc_DAL.DanhMucNhanSu_ListAll();
        }

        public static List<DanhMuc.DanhMucKhachHang> DanhMucKhachHang_ListAll()
        {
            return DanhMuc_DAL.DanhMucKhachHang_ListAll();
        }

        public static List<DanhMuc.DanhMucNhanHang> DanhMucNhanHang_ListAll()
        {
            return DanhMuc_DAL.DanhMucNhanHang_ListAll();
        }

        public static DanhMuc.DanhMucNhomNganh NhomNganh_GetByNhanHang(long NhanHangID)
        {
            return DanhMuc_DAL.NhomNganh_GetByNhanHang(NhanHangID);
        }

        public static List<DanhMuc.HinhThucQuangCao> HinhThucQuangCao_ListAll()
        {
            return DanhMuc_DAL.HinhThucQuangCao_ListAll();
        }

        public static List<DanhMuc.SanPham> SanPham_GetByHinhThucQuangCao(string hinhthucquangcaoID)
        {
            return DanhMuc_DAL.SanPham_GetByHinhThucQuangCao(hinhthucquangcaoID);
        }

        public static List<DanhMuc.DonViTinh> DonViTinh_GetBySanPham(long sanphamID)
        {
            return DanhMuc_DAL.DonViTinh_GetBySanPham(sanphamID);
        }

        public static List<DanhMuc.Website> Website_SelectAll()
        {
            return DanhMuc_DAL.Website_SelectAll();
        }

        public static List<DanhMuc.ChuyenMuc> ChuyenMuc_SelectAll()
        {
            return DanhMuc_DAL.ChuyenMuc_SelectAll();
        }

        public static List<DanhMuc.Banner> Banner_SelectAll()
        {
            return DanhMuc_DAL.Banner_SelectAll();
        }


        public static List<DanhMuc.Tag> Tag_SelectAll()
        {
            return DanhMuc_DAL.Tag_SelectAll();
        }

        public static List<DanhMuc.TaiKhoanAdmk> TaikhoanAdmk_SelectAll()
        {
            return DanhMuc_DAL.TaikhoanAdmk_SelectAll();
        }

        public static List<DanhMuc.BaoGiaHopDong> BaoGiaHopDong_FilterDonGia(string hinhthucquangcaoID, string SanPhamID, string donvitinh, string TagID, string WebsiteID, string ChuyenMucID, string BannerID)
        {
            return DanhMuc_DAL.BaoGiaHopDong_FilterDonGia(hinhthucquangcaoID, SanPhamID, donvitinh, TagID, WebsiteID, ChuyenMucID, BannerID);
        }
        #endregion

        #region HopDong
        public static string HopDong_CountHDByDanhMucHopDong(long DanhMucHopDongID)
        {
            return HopDong_DAL.HopDong_CountHDByDanhMucHopDong(DanhMucHopDongID);
        }


        public static long LuuHopdong(QLHD.Entity.Manipulation.HopDong.objHD objHD,int status)
        {
            return HopDong_DAL.LuuHopdong(objHD, status);
        }

        public static bool HuyHopdong(long hopdongID)
        {
             return HopDong_DAL.Delete_Hopdong(hopdongID);
        }

        public static bool UpdateSale(long hopdongID, long saleID)
        {
            return HopDong_DAL.UpdateSale(hopdongID, saleID);
        }

        public static bool UpdateKhachHang(long hopdongID, long khachhangID)
        {
            return HopDong_DAL.UpdateKhachHang(hopdongID, khachhangID);
        }

        public static HopDong.objHD EditHopdong(long HopDongID)
        {
            return HopDong_DAL.EditHopdong(HopDongID);
        }

        public static List<HopDong.ListHD> ListHopdong(string keyword , int pageIndex , int pageSize,out int totalRecords)
        {
            return HopDong_DAL.ListHopdong(keyword , pageIndex , pageSize,out totalRecords);
        }

        public static HopDong.objHD GetHopDongByHopDongID(long HopDongID)
        {
            return HopDong_DAL.GetHopDongByHopDongID(HopDongID);
        }

        public static List<HopDong.NoiDungHD> GetNoiDungHopDongByHopDongID(long HopDongID)
        {
            return HopDong_DAL.GetNoiDungHopDongByHopDongID(HopDongID);
        }

        
        #endregion


        #region Login
        public static DataTable ValidateUser(string Name, string Password)
        {
            DataTable dt = ValidateUserGetData(Name, Password);
            if (dt != null && dt.Rows.Count > 0)
                return dt;
            else
                return null;
        }

        public static DataTable ValidateUserGetData(string Name, string Password)
        {
            DataTable dt = new DataTable();
            using (MainDB db = new MainDB())
            {
                dt = db.StoredProcedures.Users_ValidateUser(Name, Password);
            }
            return dt;
        }

        public static DataTable Users_GetInfoByName(string Name)
        {
            DataTable dt = Users_GetInfoByNameGetData(Name);
            if (dt != null && dt.Rows.Count > 0)
                return dt;
            else
                return null;
        }

        public static DataTable Users_GetInfoByNameGetData(string Name)
        {
            DataTable dt = new DataTable();
            using (MainDB db = new MainDB())
            {
                dt = db.StoredProcedures.Users_GetInfoByName(Name);
            }
            return dt;
        }
        #endregion
       
    }
}



